package com.study.zookeeper;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;

import java.io.IOException;

public class Test {
    public static void main(String[] args) throws IOException, KeeperException, InterruptedException {

        String zkurl = "39.106.15.201:2181";
        MyWatcher myWatcher = new MyWatcher();
        ZooKeeper zk = new ZooKeeper(zkurl, 2000, null);
        String s = zk.create("/zhaochao02", "1234567".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
        System.out.println("s=" + s);
        zk.exists("/zhaochao02", true);
        byte[] data = zk.getData(s, myWatcher, null);
        System.out.println(new String(data));
        System.in.read();
    }
}
